<template>
	<div class="warp">
		<el-row :gutter="24">
			<el-form ref="elForm" :model="formData" :rules="rules" size="medium " label-width="10px">
				<!-- 保养编号 -->
				<el-col :span="5">
					<el-form-item label-width="70px" label="保养编号" prop="field102">
						<el-input v-model="formData.field102" placeholder="保养编号" clearable :style="{ width: '100%' }"> </el-input>
					</el-form-item>
				</el-col>
				<!-- ID -->
				<el-col :span="5">
					<el-form-item label-width="70px" label="ID" prop="field102">
						<el-input v-model="formData.field102" placeholder="ID" clearable :style="{ width: '100%' }"> </el-input>
					</el-form-item>
				</el-col>
				<!-- 设备名称 -->
				<el-col :span="5">
					<el-form-item label-width="70px" label="设备名称" prop="field102">
						<el-input v-model="formData.field102" placeholder="设备名称" clearable :style="{ width: '100%' }"> </el-input>
					</el-form-item>
				</el-col>
				<!-- 保养项目 -->
				<el-col :span="5">
					<el-form-item label-width="70px" label="保养项目" prop="field102">
						<el-input v-model="formData.field102" placeholder="保养项目" clearable :style="{ width: '100%' }"> </el-input>
					</el-form-item>
				</el-col>
				<!-- 保养要求 -->
				<el-col :span="4">
					<el-form-item label-width="70px" label="保养要求" prop="field102">
						<el-input v-model="formData.field102" placeholder="保养要求" clearable :style="{ width: '100%' }"> </el-input>
					</el-form-item>
				</el-col>

				<!-- 负责部门 -->
				<el-col :span="5">
					<el-form-item prop="field101" label-width="70px" label="负责部门">
						<el-select v-model="formData.field101" placeholder="请选择负责部门" clearable :style="{ width: '100%' }">
							<el-option v-for="(item, index) in field101Options" :key="index" :label="item.label" :value="item.value" :disabled="item.disabled"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<!-- 负责人 -->
				<el-col :span="5">
					<el-form-item prop="field101" label-width="70px" label="负责人">
						<el-select v-model="formData.field101" placeholder="请选择负责人" clearable :style="{ width: '100%' }">
							<el-option v-for="(item, index) in field101Options" :key="index" :label="item.label" :value="item.value" :disabled="item.disabled"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<!-- 保养周期 -->
				<el-col :span="5">
					<el-form-item prop="field101" label-width="70px" label="保养周期">
						<el-select v-model="formData.field101" placeholder="请选择保养周期" clearable :style="{ width: '100%' }">
							<el-option v-for="(item, index) in field101Options" :key="index" :label="item.label" :value="item.value" :disabled="item.disabled"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<!-- 状态 -->
				<el-col :span="5">
					<el-form-item prop="field101" label-width="70px" label="状态">
						<el-select v-model="formData.field101" placeholder="请选择状态" clearable :style="{ width: '100%' }">
							<el-option v-for="(item, index) in field101Options" :key="index" :label="item.label" :value="item.value" :disabled="item.disabled"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<!-- 完成分析 -->
				<el-col :span="4">
					<el-form-item prop="field101" label-width="70px" label="完成分析">
						<el-select v-model="formData.field101" placeholder="请选择完成分析" clearable :style="{ width: '100%' }">
							<el-option v-for="(item, index) in field101Options" :key="index" :label="item.label" :value="item.value" :disabled="item.disabled"></el-option>
						</el-select>
					</el-form-item>
				</el-col>

				<!-- 完成情况-->
				<el-col :span="5">
					<el-form-item prop="field101" label-width="70px" label="完成情况">
						<el-select v-model="formData.field101" placeholder="请选择完成情况" clearable :style="{ width: '100%' }">
							<el-option v-for="(item, index) in field101Options" :key="index" :label="item.label" :value="item.value" :disabled="item.disabled"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<!-- 所属船舶 -->
				<el-col :span="5">
					<el-form-item prop="field101" label-width="70px" label="所属船舶">
						<el-select v-model="formData.field101" placeholder="请选择所属船舶" clearable :style="{ width: '100%' }">
							<el-option v-for="(item, index) in field101Options" :key="index" :label="item.label" :value="item.value" :disabled="item.disabled"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<!-- 保养类型 -->
				<el-col :span="5">
					<el-form-item prop="field101" label-width="70px" label="保养类型">
						<el-select v-model="formData.field101" placeholder="请选择保养类型" clearable :style="{ width: '100%' }">
							<el-option v-for="(item, index) in field101Options" :key="index" :label="item.label" :value="item.value" :disabled="item.disabled"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<!-- 保养来源 -->
				<el-col :span="5">
					<el-form-item prop="field101" label-width="70px" label="保养来源">
						<el-select v-model="formData.field101" placeholder="请选择保养来源" clearable :style="{ width: '100%' }">
							<el-option v-for="(item, index) in field101Options" :key="index" :label="item.label" :value="item.value" :disabled="item.disabled"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<!-- 老旧船标识 -->
				<el-col :span="4">
					<el-form-item prop="field101" label-width="85px" label="老旧船标识">
						<el-select v-model="formData.field101" placeholder="请选择老旧船标识" clearable :style="{ width: '100%' }">
							<el-option v-for="(item, index) in field101Options" :key="index" :label="item.label" :value="item.value" :disabled="item.disabled"></el-option>
						</el-select>
					</el-form-item>
				</el-col>

				<!-- 是否PMS或CMS项目 -->
				<el-col :span="5">
					<el-form-item prop="field101" label-width="150px" label="是否PMS或CMS项目">
						<el-select v-model="formData.field101" placeholder="请选择是否" clearable :style="{ width: '100%' }">
							<el-option v-for="(item, index) in field101Options" :key="index" :label="item.label" :value="item.value" :disabled="item.disabled"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<!-- 日期 -->
				<el-col :span="10">
					<el-form-item label-width="70px" label="日期" prop="field103">
						<el-date-picker
							type="daterange"
							v-model="formData.field103"
							format="yyyy-MM-dd"
							value-format="yyyy-MM-dd"
							:style="{ width: '100%' }"
							start-placeholder="开始日期"
							end-placeholder="结束日期"
							range-separator="至"
							clearable
						></el-date-picker>
					</el-form-item>
				</el-col>
			</el-form>
		</el-row>

		<el-button icon="el-icon-search" type="primary" @click="submitForm">查询</el-button>
		<el-button icon="el-icon-delete" @click="resetForm">重置</el-button>
		<el-button icon="el-icon-upload2" style="margin-left: 50px">导出</el-button>
		<el-button icon="el-icon-upload" type="primary" plain>离线保养</el-button>
		<el-button icon="el-icon-plus" type="primary" @click="centerDialogVisible = true">新增不定期</el-button>
		<el-button icon="el-icon-check" type="primary" plain>批量验收</el-button>

		<el-dialog title="新增不定期" :visible.sync="centerDialogVisible" width="30%" center>
			<div>
				<el-form ref="elForm" :model="formData" :rules="rules" label-width="10px" label-position="top">
					<!--  船名 -->
					<el-col :span="24">
						<el-form-item prop="field101" label-width="60px" label="船名" required>
							<el-select v-model="formData.field101" placeholder="请选择船名" clearable style="width: 100%">
								<el-option v-for="(item, index) in field101Options" :key="index" :label="item.label" :value="item.value" :disabled="item.disabled"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<!-- 负责部门 -->
					<el-col :span="24">
						<el-form-item prop="field101" label-width="85px" label="负责部门" required>
							<el-select v-model="formData.field101" placeholder="请选择负责部门" clearable style="width: 100%">
								<el-option v-for="(item, index) in field101Options" :key="index" :label="item.label" :value="item.value" :disabled="item.disabled"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-radio v-model="radio" label="1">添加计划</el-radio>
					<el-radio v-model="radio" label="2">批量执行</el-radio>
				</el-form>
			</div>
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
				<el-button @click="centerDialogVisible = false" style="margin-left: 100px">取 消</el-button>
			</div>
		</el-dialog>
		<el-table :data="tableData" style="width: 100%; margin: 20px 0" max-height="500" border>
			<el-table-column fixed type="selection" width="55" align="center"> </el-table-column>
			<el-table-column fixed prop="date" label="保养年份" align="center"> </el-table-column>
			<el-table-column prop="province" label="船名" align="center"> </el-table-column>
			<el-table-column prop="city" label="部门" align="center"> </el-table-column>
			<el-table-column prop="type" label="保养项数" align="center"> </el-table-column>
			<el-table-column prop="address" label="申请类型" align="center"> </el-table-column>
			<el-table-column prop="zip" label="提交时间" align="center"> </el-table-column>
			<el-table-column prop="zip" label="状态" align="center"> </el-table-column>
			<el-table-column label="操作" width="210" fixed="right" align="center">
				<template slot-scope="scope">
					<el-button @click.native.prevent="deleteRow(scope.$index, tableData)" type="danger" plain size="medium">删除</el-button>
				</template>
			</el-table-column>
		</el-table>
		<el-drawer title="月度保养" :visible.sync="drawer" :direction="direction" size="90%">
			<span>我来啦!</span>
		</el-drawer>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				formData: {
					field101: undefined,
					field102: undefined,
					field103: undefined,
					field105: undefined,
					field106: [1],
				},
				rules: {
					field101: [],
					field102: [
						{
							message: "搜索关键字",
							trigger: "blur",
						},
					],
					field106: [],
				},
				field101Options: [
					{
						label: "自修",
						value: 1,
					},
					{
						label: "厂修",
						value: 2,
					},
				],
				field106Options: [
					{
						label: "隐藏其他人草稿单",
						value: 1,
					},
				],
				checked: false,
				tableData: [
					{
						date: "SP-S25020601",
						name: "RA-25011901",
						province: "华福油",
						city: "轮机部",
						type: "自修",
						address: "紧急",
						zip: "2025-02-06",
					},
				],
				centerDialogVisible: false,
				radio: "1",
				isPreparation: false,
				isDisabled: false,
				drawer: false,
				direction: "rtl",
			};
		},
		created() {},
		methods: {
			submitForm() {
				this.$refs["elForm"].validate((valid) => {
					if (!valid) return;
					// TODO 提交表单
				});
			},
			resetForm() {
				this.$refs["elForm"].resetFields();
			},
			isSelf(e) {
				console.log(e);
				if (e == 1) {
					this.isPreparation = true;
				} else {
					this.isPreparation = false;
				}
			},
			toSettlement() {
				this.$router.push({
					path: "/maintenance/settlement",
					params: {},
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	.warp {
		padding: 30px 20px;
		background-color: white;
		margin: 15px;
		border-radius: 20px;
		height: calc(100vh - 120px);
		overflow: auto;
	}
</style>
